if RFirst then
RFirst = 1;
else
RFirst = 2;
end
if RFirst == 2 then
RCount = 1;
end
if RFirst == 1 then
RCount = RCount+1;
end
if RCount > 2 then
RCount = 1
end
if RCount == 1 then 
require "import"
task(100,function()
require "import"
import "android.content.Context"
import "android.content.pm.PackageManager"
import "android.hardware.camera2.*"
import "android.os.Build"
import "android.os.Bundle"
import "java.util.jar.Manifest"
import "android.provider.*"

local hasFlash = service.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
local cameraManager  = service.getSystemService(this.CAMERA_SERVICE)
local cameraId = cameraManager.cameraIdList[0]

cameraManager.setTorchMode(cameraId,true)
service.speak(" flashlight turned  on")
return true
end)
else
if RCount == 2 then  
task(100,function()
require "import"
import "android.content.Context"
import "android.content.pm.PackageManager"
import "android.hardware.camera2.*"
import "android.os.Build"
import "android.os.Bundle"
import "java.util.jar.Manifest"
import "android.provider.*"

local hasFlash = service.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)
local cameraManager  = service.getSystemService(this.CAMERA_SERVICE)
local cameraId = cameraManager.cameraIdList[0]

cameraManager.setTorchMode(cameraId,false)
service.speak(" flashlight turned off")
return true
end)
end
end